<?php require_once('Connections/con2.php'); ?>

<?php

	if( isset($_SESSION["autenticado"]) != true){
		header("Location: /sgs/?index.php&pg=login&res=erro");
	}


	$id = $_GET['id'];

	mysql_select_db($database_con2, $con2);
	$query_rs_req = "SELECT * FROM requisicoes where id = '$id'";
	$rs_req = mysql_query($query_rs_req, $con2) or die(mysql_error());
	$row_rs_req = mysql_fetch_assoc($rs_req);
	$totalRows_rs_req = mysql_num_rows($rs_req);
	
	mysql_select_db($database_con2, $con2);
	$query_rs_div = "SELECT * FROM divisao";
	$rs_div = mysql_query($query_rs_div, $con2) or die(mysql_error());
	$row_rs_div = mysql_fetch_assoc($rs_div);
	$totalRows_rs_div = mysql_num_rows($rs_div);	
?>

encaminhar

<?php if ($_GET['res'] == 'sucesso' ) { ?>
<div id="resSucesso" class='success'>A requisicao foi encaminhada com sucesso!</div><?php } ?>
        
<?php if ($_GET['res'] == 'erro' ) { ?>
<div id="resErro" class='error'>Nao foi possivel encaminhar a requisicao!</div><?php } ?>

<fieldset><legend>Bem</legend>
<form id="form-requisicao" name="form-requisicao" method="post" action="files/lib/php/encaminhar-req.php" class="form">
	<input name="id_requisicao" id="id_requisicao" type="hidden" value="<?php echo $id; ?>"/>
    <table width="296" border="0">
      <tr>
        <td width="132">Objeto</td>
        <td width="154"><input name="objeto" id="objeto" type="text" value="<?php echo $row_rs_req['objeto']; ?>" readonly="yes" /></td>
      </tr>
      <tr>
        <td>Marca</td>
        <td><input name="marca" id="marca" type="text" value="<?php echo $row_rs_req['marca']; ?>" readonly="yes" /></td>
      </tr>
      <tr>
        <td>N de Serie</td>
        <td><input name="serie" id="serie" type="text" value="<?php echo $row_rs_req['serie']; ?>" readonly="yes" /></td>
      </tr>
      <tr>
        <td>N de Tombamento</td>
        <td><input name="tombamento" id="tombamento" type="text" value="<?php echo $row_rs_req['tombamento']; ?>" readonly="yes" /></td>
      </tr>
    </table>
</fieldset>

<fieldset><legend>Local a ser realizado o servico</legend>
    <table width="429" border="0">
      <tr>
        <td width="132">Unidade</td>
        <td width="154"><input name="unidade" id="unidade" type="text" value="<?php echo $row_rs_req['unidade']; ?>" readonly="yes" /></td>
      </tr>
      <tr>
        <td>Setor</td>
        <td><input name="setor" id="setor" type="text" value="<?php echo $row_rs_req['setor']; ?>" style="width:335px;" readonly="yes" /></td>
      </tr>
      <tr>
        <td>Localizacao</td>
        <td><input name="localizacao" id="localizacao" type="text" value="<?php echo $row_rs_req['localizacao']; ?>" style="width:335px;" readonly="yes" /></td>
      </tr>        
    </table>
</fieldset>

<fieldset><legend>Descricao do servico</legend>
    <table width="606" border="0">
      <tr>
        <td width="132">Data de Solicitacao</td>
        <td width="464"><input name="data" id="data" type="text" value="<?php $data = $row_rs_req['data']; echo date("d/m/Y", strtotime($data));?>" readonly="yes" /></td>
      </tr>
      <tr>
        <td>Descricao</td>
        <td><textarea name="descricao" id="descricao" cols="40" rows="5" readonly="yes"><?php echo $row_rs_req['descricao']; ?></textarea></td>
      </tr>
      <tr>
        <td>Divisao*</td>
        <td><select name="divisao" id="divisao" style="width:153px;">
			<option value="">Selecione a Divisao</option>                    
			<?php do { ?>
  				<option value="<?php echo $row_rs_div['nome']; ?>"><?php echo $row_rs_div['nome']; ?></option>
            <?php } while ($row_rs_div = mysql_fetch_assoc($rs_div)); ?></td>
      </tr>      
    </table>
</fieldset>
	<table>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>             
        <tr><td colspan="2">
            <input name="btnEnviar" type="submit" value="Encaminhar" class="button"/>
            <a href="?index.php&pg=inicio"><input name="btnCancelar" type="button" value="Cancelar" class="button"/></a>
			<a href="files/lib/php/requisicao-deletar.php?id=<?php echo $id; ?>"><input name="btnExcluir" type="button" value="Excluir" class="button"/></a></td>
      </tr>
	</table>
</form>  